<?php 

    foreach ($permisos as $permiso) {
        $valor[$permiso->getId()] = $permiso->getId();
    }

?>

<div id="boxAlerta">

<div class="boxAlerta-title">
                <img  style=" float: left; margin-right: 8px; " src="/images/callcenter/alarmaW.png" alt="alarma" title="alarma" /> 
                Alerta configurada cliente [ <?php echo count($mensaje_alertas) ?> ]
                <!--<a href="javascript:void(0);" onclick="<?php echo $urlLoadUserClose; ?>" class="close-windows" style="margin-right: 12px;">
                <img src="/images/icon/remove.png" title="Close"  />
                </a> -->
            </div>
    
    <?php 
    
    
    foreach ($mensaje_alertas as $cliente){ ?>
          <div class="boxAlerta-content">
              <a class="boxAlerta-cod" id="abrirAlert" target="_blank" href="<?php echo url_for('dashboard/adicionalBusq?usuarioid='.$cliente->getUsuarioId().'&alerta_id='.$cliente->getId()) ?>">DF<?php echo $cliente->getUsuarioId(); ?></a>
              Referido: <?php echo $cliente->getAgente(); ?> <br>
              Cliente: <?php echo $cliente->getUsuario(); ?><br>
              <?php 
              
                        $hora = explode(" ",$cliente->getFecha()); 
                        if($hora[1]!='00:00:00')
                        echo 'Hora: '.$hora[1];
                        
                        if(($hora[1]=='00:00:00')&&($valor[2])){              
              ?>
              <a href="javascript:void(0);" onclick="clienteStatus();">[ Aprobado ]</a>  
              <?php } ?>
          </div>
          
          <div class="boxAlerta-msn">
              <?php echo $cliente->getNota(); ?>  
          </div>
    
    <?php } ?>
    <a href="javascript:void(0);" onclick="clienteStatus();">[ Aprobado ]</a>  
    <div class="clear"></div>
</div>


<script type="text/javascript">


 function checkTime(i)
        {if (i<10) {i="0" + i;}return i;}

    function clienteStatus(){
        
        
        
         today=new Date();
                            h=today.getHours();
                            m=today.getMinutes();
                            s=today.getSeconds();
                            m=checkTime(m);
                            s=checkTime(s);

                            var horaActual = '<?php echo date('Y-m-d');?> '+h+":"+m+":"+s;
                            
        
        
        $.ajax({
                url: '<?php echo url_for('dashboard/adicionalBusq?usuarioid='.$cliente->getUsuarioId().'&alerta_id='.$cliente->getId());?>',
                type: 'POST',
                success: function(theResponse){
                            
                            
                            //$('#boxAlertaBox').hide();
                    
                             $.ajax({
                            url: '<?php echo url_for('alertaCliente/count')?>',
                            data: 'horaActual='+horaActual,
                            type: "POST",
                            success: function(theResponse){

                                if(parseInt(theResponse)!=0){
                                    $('#boxAlertaBox').html(theResponse).show();
                                }else{
                                $('#boxAlertaBox').hide();
                                }
                                
                            }});

                    
                    
                }});

               
    }

$('#abrirAlert').click(function (){

$('#boxAlertaBox').hide();

});




</script>